import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import router from './router';
import store from './store';
import Cookie from 'js-cookie'
// 引入mock
import './api/mock'
import axios from 'axios'			//引入axios
Vue.config.productionTip = false


axios.defaults.baseURL = 'http://localhost:8080'        //关键代码
Vue.prototype.$axios = axios
axios.defaults.timeout = 5000
axios.defaults.headers.common['Authorization'] = Cookie.get("token");	//Web API 验证
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';	//设置默认编码方式为



// Vue.use(Row);
// Vue.use(Button);
Vue.use(ElementUI);


// //添加全局前置导航守卫  登录拦截
// router.beforeEach((to, from, next) => {
//   const token = Cookie.get('token')
//   if(!token && to.name!=='login'){
//     next({name:'login'})
//   }else if(token && to.name ==='login'){
//     next({name:'main'})
//   }else{
//     next()
//   }
// })





new Vue({
  router,
  store,
  render: h => h(App),
  created(){
    store.commit('addMenu',router)
  },
}).$mount('#app')
